Add language-wide chat routing via TOC and scope selector in chat form#222
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
my-code | d9f60ea | Commit Preview URL Branch Preview URL |
Jul 21 2026, 05:20 PM |
Copilot
AI
changed the title
[WIP] Implement feature to categorize questions by page
Add language-wide chat routing via TOC and scope selector in chat form
Jul 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the docs chat feature to support a user-selectable question scope (“current page” vs “entire language”) and adds an AI-driven routing step that selects the most relevant page (based on the language TOC) when the language scope is chosen.
Changes:
- Added
questionScope: "page" | "language"to chat requests and updated/api/chatto optionally route to another page within the same language. - Extended the initial streamed
chatevent withpagePathso the client can revalidate and scroll against the routed page. - Updated the chat form UI to include a scope selector and to adjust revalidation/scroll behavior based on the routed page.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| app/api/chat/route.ts | Adds language-wide routing flow and streams back the routed pagePath, using routed sections as chat context. |
| app/(docs)/@docs/[lang]/[pageId]/pageContent.tsx | Passes langName into ChatForm for rendering the language-scope radio label. |
| app/(docs)/@docs/[lang]/[pageId]/chatForm.tsx | Adds scope selector UI, sends questionScope, and revalidates/scrolls based on routed pagePath. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+82
to
+91
| for (const page of langEntry.pages) { | ||
| const sections = await getMarkdownSections(path.lang, page.slug); | ||
| const sectionTitles = sections | ||
| .map((s) => s.title.trim()) | ||
| .filter((title) => title.length > 0) | ||
| .join(" / "); | ||
| routePrompt.push( | ||
| `- slug: ${page.slug} | 章題: ${page.title} | セクション: ${sectionTitles}` | ||
| ); | ||
| } |
Comment on lines
25
to
29
| interface ChatFormProps { | ||
| path: PagePath; | ||
| langName: string; | ||
| sectionContent: DynamicMarkdownSection[]; | ||
| close: () => void; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
na-trium-144
marked this pull request as ready for review
July 21, 2026 17:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current chat answers only reference the currently open page. This change adds a user-selectable scope so questions can be answered from either the current page or the entire current language, with AI routing to the most relevant page using that language’s TOC.
Scope selection in chat UI
このページの内容について質問(言語名)全体について質問questionScope: "page" | "language"with chat requests.Language-wide routing flow in
/api/chatquestionScope === "language":null).questionScope === "page":Chat event payload and cache revalidation alignment
pagePathof the actual routed target.